import { downloadFile, getFileInfoByIds, previewImg } from '@/api/file'
import { HsAdminBaseUpload } from '@hs-admin/base-components'
import { FC, memo } from 'react'
import type { UploadProps } from 'antd'

type IdsType = number[] | string | number
interface Props extends UploadProps {
  // 是否支持多选文件
  multiple?: boolean
  // 文件id数组
  ids?: IdsType
  // 更新外部传入的文件
  updateFile?: (ids: IdsType) => void
  children?: any
  // 接受上传的文件类型
  accept?: string
  // 标题，默认值：上传文件
  title?: string
  // 隐藏默认预览，自定义预览
  hidePreview?: boolean
}
const GlobalUpload: FC<Props> = (props: Props) => {
  const action = `${import.meta.env.VITE_BUSINESS_API_URL}/api/datamarket/file/upload`
  return (
    <HsAdminBaseUpload
      action={action}
      downloadFile={downloadFile}
      getFileInfoByIds={getFileInfoByIds}
      previewImg={previewImg}
      {...props}></HsAdminBaseUpload>
  )
}

export default memo(GlobalUpload)
